{extend name="public/base" /}
{block name="title"}
<h1>修改密码</h1>
{/block}
{block name="content"}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header">
                </div>
                <form class="form-horizontal" action="{:url('user/editPassword')}" method="post" id="subForm">
                    {:token()}
                    <input type="hidden" name="id" id="id" value="{$id}">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="oldPassword" class="col-sm-3 control-label"><span class="text-danger">* </span>旧密码</label>
                            <div class="col-sm-4">
                                <input type="password" class="form-control" id="oldPassword" name="oldPassword"
                                       value="{$Think.session.form_info.oldPassword|default=''}" placeholder="旧密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="newPassword" class="col-sm-3 control-label"><span class="text-danger">* </span>新密码</label>
                            <div class="col-sm-4">
                                <input type="password" class="form-control" id="newPassword" name="newPassword"
                                       value="{$Think.session.form_info.newPassword|default=''}" placeholder="新密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="checkPassword" class="col-sm-3 control-label"><span class="text-danger">* </span>确认密码</label>
                            <div class="col-sm-4">
                                <input type="password" class="form-control" id="checkPassword" name="checkPassword"
                                       value="{$Think.session.form_info.checkPassword|default=''}" placeholder="确认密码">
                            </div>
                        </div>
                    </div>
                    <div class="box-footer">
                        <a href="javascript:" class="btn btn-default" onclick="doGoBack()">
                            <i class="fa fa-arrow-left"></i>返回
                        </a>
                        <button type="submit" class="btn btn-primary col-md-offset-3">
                            <i class="fa fa-save"></i>保存
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
{/block}
{block name="script"}
{load href="/static/common/js/validate/jquery.validate.min.js"}
{load href="/static/common/js/validate/messages_zh.min.js"}
{load href="/static/common/js/validate/base.validate.js"}
<script type="text/javascript">
    var doGoBack = function () {
        history.go(-1);
    };
    $(function () {
        var e = "<i class='fa fa-times-circle'></i>";
        $("#subForm").validate({
            rules: {
                oldPassword: {
                    required: true
                },
                newPassword: {
                    required: true,
                    rangelength: [6, 16]
                },
                checkPassword: {
                    required: true,
                    equalTo: "#newPassword"
                }
            },
            messages: {
                oldPassword: {
                    required: e + "请输入旧密码"
                },
                newPassword: {
                    required: e + "请输入新密码",
                    rangelength: e + "密码长度在6到16个字符之间"
                },
                checkPassword: {
                    required: e + "请输入确认密码",
                    equalTo: e + "两次输入密码不一致"
                }
            }
        });
    });
</script>
{/block}